package com.thread.thread05;
/**
 * synchronized异常
 * @author alienware
 *
 */
public class SyncException {

	int t = 0;
	public synchronized void operation() {
		while(true) {
			try{
				t++;
				Thread.sleep(200);
				System.out.println(Thread.currentThread().getName() + " t= " + t);
			    if(t==20) {
			    	//throw new RuntimeException();
			    	Integer.parseInt("a");
			    }
			}catch(InterruptedException e) {
				e.printStackTrace();
				System.out.println( "gh122122");
			}
		}
	}
	
	public static void main(String[] args) {
		SyncException sy = new SyncException();
		Thread t = new Thread(new Runnable() {
			
			@Override
			public void run() {
				sy.operation();
				
			}
		});
		t.start();
	}
}
